package com.tyk.bookstore.back.product.model.enume;


import com.fasterxml.jackson.annotation.JsonValue;
import com.tyk.bookstore.back.common.core.model.type.BaseEnum;
/**
 * @author tyk
 * @description 书籍状态
 */
public enum BookState implements BaseEnum {
    OFF(0),
    ON(1);

    @JsonValue
    private final Integer code;

    @Override
    public Integer value() {
        return this.code;
    }

    public static BookState getBookState(Integer code) {
        for (BookState value : BookState.values()) {
            if(value.value()==code) return value;
        }
        throw new RuntimeException();
    }

    BookState(Integer code) {
        this.code = code;
    }

    public static void main(String[] args) {
        Integer code = 0;
        BookState bookState = BookState.getBookState(code);
    }
}
